package byggeTegning.husGeometri;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

import javax.media.j3d.Appearance;
import javax.media.j3d.Group;
import javax.media.j3d.Shape3D;
import javax.vecmath.Color3f;

import byggeTegning.geometry.Cube;
import byggeTegning.geometry.Object3D;
import byggeTegning.geometry.Point3D;
import byggeTegning.geometry.TransformedGroup3D;


// ***************************************************************************
// *** CLASS: Pilar
// ***************************************************************************
public class Pilar extends Block
{ 
  public Pilar
  (String ident,Point3D p0,double width,double height,double depth)
  { super(ident,p0.addY(-height),width,height,depth);
  }
    
  
  // ***************************************************************************
  // *** METHOD: getModel3D
  // ***************************************************************************
  public /*abstract*/ Group getModel3D(Color3f c)
  { TransformedGroup3D tg=new TransformedGroup3D();
    tg.setSize(width,height,depth);
    tg.setP0(p0.x,p0.y,p0.z);
//    tg.setAngles(new Vector3d(1.0,0.0,0.0));
//    tg.setAngleX(Math.PI/2);  
//    tg.setAngleY(Math.PI/2);  
//    tg.setAngleZ(Math.PI/2);  
    Shape3D shape=new Cube();
    Appearance app=Object3D.createAppearance(8,c);
    shape.setAppearance(app);
    tg.addChild(shape);
    return(tg);
  }  
    

  public void drawProjection(int direction,Graphics2D g,Point2D.Double origo2D,double scale,Color c)
  { Rectangle2D.Double r=projection(direction,origo2D,scale);
    if(c!=null) c=pilarFarge;
    switch(direction)
    {
//      case NORTH: tegnPipeFasade(g,r,scale,c); break;
//      case SOUTH: tegnPipeFasade(g,r,scale,c); break;
//      case EAST: tegnPipeFasade(g,r,scale,c); break;
//      case WEST: tegnPipeFasade(g,r,scale,c); break;
//      case ABOVE: drawProjectionAbove(g,r,scale,c); break;
//      case BELOW: drawProjectionBelow(g,r,scale,c); break;
      case VCUT: drawVerticalCut(g,r,scale,c); break;
      case HCUT: drawHorisontalCut(g,r,scale,c); break;
      default: super.drawProjection(direction,g,origo2D,scale,c);
    }  
  }
      
  private void drawHorisontalCut(Graphics2D g,Rectangle2D.Double r,double scale,Color c)
  {
//    if(c!=null) c=pilarFarge;
//    fill(g,r,c);
//    draw(g,r);
  }

  private void drawVerticalCut
  (Graphics2D g,Rectangle2D.Double r,double scale,Color c)
  { if(c!=null) c=pilarFarge;
    fill(g,r,c);
//    draw(g,r);
  }

}
